package cn.com.shadowless.xinning.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.shadowless.xinning.R;
import cn.com.shadowless.xinning.model.order.AssetApplyInfo;
import cn.com.shadowless.xinning.model.order.CompanyBudgetOrderInfo;
import cn.com.shadowless.xinning.model.order.DepartBudgetOrderInfo;

/**
 * The type Company budget fragment tab adapter.
 *
 * @author sHadowLess
 */
public class FragmentTabAdapter<T> extends BaseQuickAdapter<T, BaseViewHolder> {


    public FragmentTabAdapter(int layoutResId, @Nullable List<T> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, T item) {
        if (item instanceof CompanyBudgetOrderInfo.DataBean.BudgetTypeListBean) {
            CompanyBudgetOrderInfo.DataBean.BudgetTypeListBean budgetTypeListBean = (CompanyBudgetOrderInfo.DataBean.BudgetTypeListBean) item;
            String budgetTypeName = budgetTypeListBean.getBudgetTypeName();
            helper.setText(R.id.tab_name, budgetTypeName);
            helper.addOnClickListener(R.id.tab_item);
        } else if (item instanceof DepartBudgetOrderInfo.DataBean.BudgetTypeListBean) {
            DepartBudgetOrderInfo.DataBean.BudgetTypeListBean budgetTypeListBean = (DepartBudgetOrderInfo.DataBean.BudgetTypeListBean) item;
            String budgetTypeName = budgetTypeListBean.getBudgetTypeName();
            helper.setText(R.id.tab_name, budgetTypeName);
            helper.addOnClickListener(R.id.tab_item);
        } else if (item instanceof AssetApplyInfo.DataDTO.ItemListDTO) {
            AssetApplyInfo.DataDTO.ItemListDTO itemListDTO = (AssetApplyInfo.DataDTO.ItemListDTO) item;
            String budgetTypeName = itemListDTO.getAssetName();
            helper.setText(R.id.tab_name, budgetTypeName);
            helper.addOnClickListener(R.id.tab_item);
        }
    }
}
